// 住院管理
<template>
  <el-row>
    <el-col :span="24" class="section-option">
      <TopManu
        :TopArr3="TopArr3"
        :TopArr2="TopArr2"
        @handcreate="handcreate"
        @handelDropdown2="handelDropdown"
        @handelDropdown="handelDropdown2"
        @handdepositset="handdepositset"
        @handdeposit="handdeposit"
        @handjsdata='handjsdata'
        @handdejiaoyi='handdejiaoyi'

      ></TopManu>

    </el-col>
    <el-col :span="24">
      <el-col :span='24' >
      <div class='zaiinfo'> 全院 | 【在院人数{{data_info.count}}人 今日入院:{{data_info.todayEnter}}人
         今日出院:{{data_info.todayLeave}}人 】</div>
      </el-col>
      <el-col :span="24" style='padding:10px'>
        <el-form :inline="true"  class="demo-form-inline" v-model="formInline">
          <el-form-item label="搜索">
            <el-input
              placeholder="请输入姓名/门诊号/身份证号"
              v-model="formInline.rightKeyValue"
              clearable
              @change="radiochang"
              size="small"
            >
              <el-button type="success"
                slot="append"
                icon="el-icon-search"
                @click="radiochang"
              >
                查询
              </el-button>
            </el-input>
          </el-form-item>
           <!-- <el-form-item label="当天入院" >
          <el-checkbox v-model="formInline.today"  @change="radiochang"></el-checkbox>
          </el-form-item> -->

          <el-form-item label="类型">
            <el-select
              v-model="formInline.rightRadio"
              @change="radiochang"
              multiple
              placeholder="类型"
              size="small"
            >
              <el-option
                v-for="(item,it) in Radiooptions"
                :key="it"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <!-- <el-form-item label="范围">
            <el-select
              v-model="formInline.range"
              @change="radiochang"
              placeholder="范围"
              size="small"
            >
              <el-option
                v-for="item in Radiooptions2"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-form-item> -->
          <el-form-item label="病区">
            <el-select
              v-model="formInline.icu_id"
              @change="radiochang"
              placeholder="病区"
              width='300'
              size="small"
            >
            <el-option
                label="全部"
                value=""
              >
              </el-option>
              <el-option
                v-for="(item,index) in getBuildlist"
                :key="index"
                :label="item.name"
                :value="item.id"
              >
                <span style="float: left">{{ item.name }}</span>
                <span style="float: right; color: #8492a6; font-size: 13px">占 {{ item.full_bed_count }}</span>
      <span style="float: right; color: #8492a6; font-size: 13px">空 {{ item.empty_bed_count }}</span>
              </el-option>

            </el-select>
          </el-form-item>
                 <el-form-item label="病人性质">
            <el-select
              v-model="formInline.nature"
              @change="radiochang"
              placeholder="性质"
              size="small"
            >
             <el-option

                label="全部"
                value=""
              >
              </el-option>
              <el-option
                v-for="(item,index) in member_lv"
                :key="index"
                :label="item.name"
                :value="item.id"
              >
              </el-option>
            </el-select>
          </el-form-item>

        </el-form>

        <el-table
          :data="patientlist"

        border
          style="width: 100%"
          @row-click="rowClick"
            :highlight-current-row='false'
          :row-class-name="tableRowClassName"

        >
          <el-table-column type="index" width="50"> </el-table-column>
          <el-table-column prop="room_name"  :show-overflow-tooltip="true" width="100" label="房间-床位">
            <!-- <template slot-scope="scope">
              {{ scope.row.room_name}}
            </template> -->

      <!-- </template> -->
          </el-table-column>

          <el-table-column prop="status" label="状态">
            <template slot-scope="scope">
              <!-- {{
                scope.row.status == 1
                  ? "待入院"
                  : scope.row.status == 2
                  ? "在院"
                  : scope.row.status == 3
                  ? "申请出院"
                  : scope.row.status == 4
                  ? "待出院"
                  : scope.row.status == 5
                  ? "已出院"
                  : ""
              }} -->
              <el-tag v-if="scope.row.status == 1||scope.row.status == 0">待入院</el-tag>
               <el-tag v-if="scope.row.status == 2" type="success">在院</el-tag>
                <el-tag v-if="scope.row.status == 3"  type="warning">申请出院</el-tag>
                 <el-tag v-if="scope.row.status == 4" type="info">待出院</el-tag>
                  <el-tag v-if="scope.row.status == 5" type="danger">已出院</el-tag>
            </template>
          </el-table-column>
             <el-table-column prop="mdtrt_name" width="" label="是否登记">
                            <template slot-scope="scope">
                         <el-popover trigger="click" placement="top">

           <el-table
    :data="tableData2"
    style="width: 100%"
    max-height="250">
    <el-table-column
      fixed
      prop="action"
      label="操作方法"
      width="150">
    </el-table-column>
    <el-table-column
      prop="remark"
      label="操作详情"
      width="120">
    </el-table-column>
    <el-table-column
      prop="create_by_name"
      label="操作人"
      width="120">
    </el-table-column>
    <el-table-column
      prop="created_at"
      label="操作时间"
      width="150">
    </el-table-column>
    <!-- <el-table-column
      prop="target_type"
      label="状态"
      width="100">

    </el-table-column>
     -->

  </el-table>
          <div slot="reference" class="name-wrapper" @click="getYbRecord(scope.row.id)">
            <!-- <el-tag size="medium">{{ scope.row.mdtrt_name }}</el-tag> -->
             <el-tag size="medium" :type="scope.row.mdtrt_name=='已登记'?'success':'danger'">{{ scope.row.mdtrt_name }}</el-tag>
          </div>
        </el-popover>
         </template>
          </el-table-column>

            <el-table-column prop="ipt_no" label="住院号"> </el-table-column>
          <el-table-column prop="member.name" label="姓名"> </el-table-column>
          <!-- <el-table-column prop="member.psn_no" width="250" label="人员编号">
          </el-table-column> -->
          <el-table-column prop="member.gender" label="性别"  width="50"> </el-table-column>
          <el-table-column prop="member.age" label="年龄" width="50"> </el-table-column>

                <el-table-column prop="doctor.real_name" label="主治医生">
          </el-table-column>
          <!-- <el-table-column prop="bed_doctor.real_name" label="床管医生">
          </el-table-column> -->
          <el-table-column prop="nurse.real_name" label="护士">
          </el-table-column>

           <el-table-column prop="wallet.wallet_income" label="押金">
          </el-table-column>
           <el-table-column prop="wallet.balance" label="住院费用">
          </el-table-column>
           <el-table-column prop="member.insutype" :show-overflow-tooltip="true" label="险种类型">
          </el-table-column>
            <el-table-column prop="memberNature" label="病人性质">
             <template slot-scope="scope">

              <el-tag v-if="scope.row.memberNature== '医保'">{{scope.row.memberNature}}</el-tag>
               <el-tag v-if="scope.row.memberNature == '自费'" type="success">{{scope.row.memberNature}}</el-tag>
                <el-tag v-if="scope.row.memberNature == '农保'"  type="warning">{{scope.row.memberNature}}</el-tag>

            </template>
             </el-table-column>
          <el-table-column prop="med_type" width="150" label="医疗类别">
          </el-table-column>





          <!-- <el-table-column prop="nurse_levelneme" label="护理等级">
          </el-table-column>

          <el-table-column prop="nurse.risk_level" label="风险等级">
          </el-table-column> -->

          <el-table-column prop="begntime" :show-overflow-tooltip="true"  label="入院时间">
          </el-table-column>
               <el-table-column prop="leave_time" :show-overflow-tooltip="true"  label="出院时间">
          </el-table-column>
        <el-table-column prop="day" label="入院天数">
          </el-table-column>
<!--
          <el-table-column fixed="right" label="操作" width="100">
            <template slot-scope="scope">

              <el-dropdown @command="handleCommand" trigger="click">
                <span class="el-dropdown-link">
                  更多<i class="el-icon-arrow-down el-icon--right"></i>
                </span>
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item :command="[scope.row.id, scope.$index, 'y']"
                    >押金</el-dropdown-item
                  >
                  <el-dropdown-item
                    :disabled="scope.row.status != 1"
                    :command="[scope.row.id, scope.$index, 'c']"
                    >撤销住院</el-dropdown-item
                  >
                  <el-dropdown-item

                    :command="[scope.row.id, scope.$index, 'x']"
                    >修改信息</el-dropdown-item
                  >
                  <el-dropdown-item :command="[scope.row.id, scope.$index, 'f']"
                    >入院分床</el-dropdown-item
                  >


                  <el-dropdown-item
                    :command="[scope.row.id, scope.$index, 'tj']"
                    >提交出院</el-dropdown-item
                  >
                  <el-dropdown-item
                    :command="[scope.row.id, scope.$index, 'cxtj']"
                    >撤销出院</el-dropdown-item
                  >

                         <el-dropdown-item
                    :command="[scope.row.id, scope.$index, 'qdxz']"
                    >住院清单下载</el-dropdown-item>
                         <el-dropdown-item
                    :command="[scope.row.id, scope.$index, 'qdsc']"
                    >住院清单上传</el-dropdown-item>
                </el-dropdown-menu>


              </el-dropdown>
            </template>
          </el-table-column> -->
        </el-table>

        <!-- <el-pagination
  background
  style="float:right"
   :page-size="formInline.limit"
  :pager-count="formInline.page"
  layout="prev, pager, next"
  :total="total">
</el-pagination> -->
        <el-pagination
          background
          style="float:right"
          @size-change="handleSizeChange"
          :current-page="formInline.page"
          :page-sizes="[10, 20, 30, 100]"
          :page-size="formInline.limit"
          layout="sizes , total , prev, pager, next , jumper"
          @current-change="handlePagination"
          :total="total"
        >
        </el-pagination>
        <!-- <FromList :tableTitle="tableTitle" :tableData="tableData" /> -->
      </el-col>
  </el-col>

    <!-- 押金弹框 -->
    <el-dialog :fullscreen='true' :close-on-click-modal='false' title="押金" @closed="closetan('orderinfo')" :visible.sync="dialogdeposit" width="70%">
      <infocrad :id="patientinfo.id" ref='userinfn'></infocrad>
      <viewTitle text="押金信息" style="font-size:20px;margin-bottom:20px" />
      <el-col :span="24">
        <el-col :span="10">
          <el-form
            label-position="right"
            label-width="100px"
            :model="orderinfo"
            ref='orderinfo'
          >
            <el-form-item label="微信">
              <el-input
                v-model="orderinfo.payment[0].money"
                @change="moneysumfun"
              ></el-input>
            </el-form-item>
            <el-form-item label="支付宝">
              <el-input
                v-model="orderinfo.payment[1].money"
                @change="moneysumfun"
              ></el-input>
            </el-form-item>
            <el-form-item label="现金">
              <el-input
                v-model="orderinfo.payment[2].money"
                @change="moneysumfun"
              ></el-input>
            </el-form-item>
            <el-form-item label="银联">
              <el-input
                v-model="orderinfo.payment[3].money"
                @change="moneysumfun"
              ></el-input>
            </el-form-item>
            <el-form-item label="预存">
              <el-input
                v-model="orderinfo.payment[4].money"
                @change="moneysumfun"
              ></el-input>
            </el-form-item>
            <!-- <el-form-item label="医保">
              <el-input
                v-model="orderinfo.payment[5].money"
                @change="moneysumfun"
              ></el-input>
            </el-form-item> -->
            <el-form-item label="总计">
              <el-input v-model="moneysum" disabled></el-input>
            </el-form-item>
          </el-form>
        </el-col>
        <el-col :span="2">
          <div style="width:20px"></div>
        </el-col>
        <el-col :span="10">
          <el-form
            label-position="right"
            label-width="100px"
            :model="orderinfo"
            ref='orderinfo'
          >
            <el-form-item label="小写">
              <el-input v-model="moneysum" disabled></el-input>
            </el-form-item>
            <el-form-item label="大写">
              <el-input v-model="damoneysum" disabled></el-input>
            </el-form-item>

            <el-form-item label="说明">
              <el-input type="textarea" v-model="orderinfo.des"></el-input>
            </el-form-item>
          </el-form>
        </el-col>
      </el-col>
      <div slot="footer" class="dialog-footer">
        <el-button  @click="dialogdeposit = false">取 消</el-button>
        <el-button type="success"  @click="handedeposit">保 存</el-button>
      </div>
    </el-dialog>
    <!-- 入院撤销 -->
    <el-dialog :close-on-click-modal='false' title="入院撤销" @close="closetan('cancelHospitalinfo')" :visible.sync="canceldialogdeposit" width="70%">
      <infocrad :id="patientinfo.id" ref='userinfn'></infocrad>
      <viewTitle text="入院撤销" style="font-size:20px;margin-bottom:20px" />

      <el-col :span="24">
        <el-form ref='cancelHospitalinfo' >
          <el-form-item label="撤销原因">
            <el-input
              type="textarea"
              v-model="cancelHospitalinfo.cancel_msg"
            ></el-input>
          </el-form-item>
        </el-form>
      </el-col>
      <div slot="footer" class="dialog-footer">
        <el-button  @click="canceldialogdeposit = false">取 消</el-button>
        <el-button type="success"  @click="cancelHospital">保 存</el-button>
      </div>
    </el-dialog>
    <!-- 出院结账 -->
    <!-- <el-dialog :close-on-click-modal='false' title="出院结账" :visible.sync="zhuyuandeposit" width="70%">
        <infocrad :id="patientinfo.id" ref='userinfn'></infocrad>

      <el-col :span="24">

        <jiezhang
          :patientinfo="patientinfo"
          ref="jiezhang"
          @jiezhang="jiezhang(arguments)"
        ></jiezhang>
      </el-col>
      <div slot="footer" class="dialog-footer">
        <el-button type="success" @click="zhuyuandeposit = false">取 消</el-button>
        <el-button type="success" type="success" @click="zhuyuanHospital">保 存</el-button>
      </div>
    </el-dialog> -->

    <!-- 撤销申请出院 -->
    <el-dialog :close-on-click-modal='false' title="撤销申请出院"  @close="closetan('cancelDis')" :visible.sync="cancelDischarge" width="70%">
      <infocrad :id="patientinfo.id" ref='userinfn'></infocrad>
      <viewTitle
        text="撤销申请住院"
        style="font-size:20px;margin-bottom:20px"
      />

      <el-col :span="24">
        <el-form ref='cancelDis'>
          <el-form-item label="撤销原因">
            <el-input type="textarea" v-model="cancelDis.msg"></el-input>
          </el-form-item>
        </el-form>
      </el-col>
      <div slot="footer" class="dialog-footer">
        <el-button  @click="cancelDischarge = false">取 消</el-button>
        <el-button type="success" @click="cancelDischargehade">保 存</el-button>
      </div>
    </el-dialog>
    <!-- 出院申请 -->
    <el-dialog :fullscreen='true' :close-on-click-modal='false' title="出院申请" :visible.sync="chuyuanlogdeposit" width="70%">
      <infocrad :id="patientinfo.id" ref='userinfn'></infocrad>
        <viewTitle text="诊断信息" style="font-size:20px;" />
       <el-table
    ref="singleTable"
    :data="patientinfo.disease"
    highlight-current-row

    style="width: 100%">
    <el-table-column
      type="index"
      width="50">
    </el-table-column>
    <el-table-column
      property="disease_name"
      label="诊断"
      width="120">
    </el-table-column>
    <el-table-column
      property="disease_number"
      label="诊断编号"
      width="120">
    </el-table-column>
    <el-table-column
      property="disease_id"
      label="诊断id">
    </el-table-column>
  </el-table>
      <el-col :span="24" style='margin-top:20px'>
        <el-form label-width="150px">
          <el-col :span='8'>
          <el-form-item label="申请出院时间">
            <el-date-picker
              v-model="dischargedata.apply_time"
              type="date"
              placeholder="出院时间"
              format="yyyy 年 MM 月 dd 日"
              value-format="yyyy-MM-dd"
            >
            </el-date-picker>
          </el-form-item>
          </el-col>
           <el-col :span='8'>
          <el-form-item label="出院方式">
            <el-select v-model="dischargedata.leave_way" placeholder="出院方式">
              <el-option
                v-for="(item, index) in chuyuanfangshi"
                :key="index"
                :label="item.name"
                :value="item.id"
                >{{ item.name }}</el-option
              >
            </el-select>
          </el-form-item>
            </el-col>
           <el-col :span='8'>
          <el-form-item label="出院状况">
            <el-select
              v-model="dischargedata.leave_id"
              placeholder="出院状况"
            >
              <el-option
                v-for="(item, index) in chuyuanzhuang"
                :key="index"
                :label="item.name"
                :value="item.id"
                >{{ item.name }}</el-option
              >
            </el-select>
          </el-form-item>
            </el-col>
           <el-col :span='8'>


              <el-form-item label="转院名称">
    <el-input v-model="dischargedata.leave_hospital"   style="width: 200px;"></el-input>
  </el-form-item>

          </el-col>
           <el-col :span='2'>
          <el-form-item label="随诊" label-width="50px">
              <el-checkbox-group v-model="dischargedata.leave_type">
      <el-checkbox label="" name="type"></el-checkbox>

    </el-checkbox-group>
          </el-form-item>
            </el-col>
           <el-col :span='6'>
          <el-form-item label="限期（月）" label-width="150px">
             <el-input v-model="dischargedata.leave_yue" style="width: 200px;"></el-input>
          </el-form-item>
            </el-col>
               <el-col :span='8'>
                      <el-form-item label="出院科室:">
                    <el-cascader
                      v-model="dischargedata.department_id"
                      :options="departmentoptions"
                      :props="{ label: 'name', value: 'id' }"
                      style="width: 200px;"
                      :show-all-levels="false"


                    ></el-cascader>
                  </el-form-item>
            </el-col>
           <el-col :span='24'>

          <el-form-item label="出院备注">
    <el-input type="textarea" v-model="dischargedata.leave_remark"></el-input>
  </el-form-item>
          </el-col>
        </el-form>
      </el-col>
      <div slot="footer" class="dialog-footer">
        <el-button  @click="chuyuanlogdeposit = false">取 消</el-button>
        <el-button type="success"  @click="chuyuanHospital">保 存</el-button>
      </div>
    </el-dialog>

    <el-dialog :close-on-click-modal='false' title="医嘱情况" :visible.sync="yizhulogdeposit" width="70%">
      <infocrad :id="patientinfo.id" ref='userinfn'></infocrad>
      <viewTitle text="医嘱信息" style="font-size:20px;" />
      <el-table
        ref="singleTable"
        :data="yizhuqingkuang"
        highlight-current-row
        style="width: 100%"
      >
        <el-table-column type="index" width="50"> </el-table-column>
        <el-table-column property="title" label="模块名称" >
        </el-table-column>
        <el-table-column property="cinfo" label="错误信息" >
        </el-table-column>
        <el-table-column property="" label="跳转">
        </el-table-column>
      </el-table>

      <div slot="footer" class="dialog-footer">

        <el-button type="success"  @click="yizhulogdeposit = false">确定</el-button>
      </div>
      <!-- 提交出院 -->
    </el-dialog>

      <el-dialog :close-on-click-modal='false' title="提示" center :visible.sync="chuyuantilogdeposit" width="30%">
     <el-col :span='24'>
          <h3 style='padding:0px;margin:5px'>
            提交出院后产生以下后果:
          </h3>
          </el-col>
          <el-col :span='24' style='padding:0px;margin:5px'>
         1、患者状态由申请出院变为待出院
          </el-col>
          <el-col :span='24' style='padding:0px;margin:5px'>
          2、房间床位将释放
          </el-col>
           <el-col :span='24' style='padding:0px;margin:5px'>
          是否将患者【{{patientinfo.member.name}} {{patientinfo.member.gender}}】（住院号：{{patientinfo.ipt_no}}）提交出院？
          </el-col>
             <el-col :span='24' style='padding:0px;margin:5px'>

            <el-date-picker
              v-model="apply_time"
              type="date"
              placeholder="出院时间"
              format="yyyy 年 MM 月 dd 日"
              value-format="yyyy-MM-dd"
            >
            </el-date-picker>

          </el-col>
      <div slot="footer" class="dialog-footer" style='padding:0px;margin:5px'>
      <el-button  @click="chuyuantilogdeposit = false">取 消</el-button>
        <el-button type="success" @click="tijiaochuyuan">确定</el-button>
      </div>
    </el-dialog>
     <el-dialog :fullscreen='true' :close-on-click-modal='false' title="交易冲正" center :visible.sync="jiaoyilogdeposit">
        <jiaoyi :id="patientinfo.id"></jiaoyi>
      <!-- <div slot="footer" class="dialog-footer" style='padding:0px;margin:5px'>
      <el-button type="success" @click="chuyuantilogdeposit = false">取 消</el-button>
        <el-button type="success" type="success" @click="tijiaochuyuan">确定</el-button>
      </div> -->
    </el-dialog>
    <!-- 入院办理 -->
    <el-dialog :fullscreen='true' :close-on-click-modal='false'
      title="入院信息"
      width="80%"
      @close="closeuser"
      :visible.sync="dialogFormVisible1"
    >
      <Create
        ref="create"
        :userdata="userdata"
        @hospitalization="hospitalization(arguments)"

      ></Create>
      <div slot="footer" class="dialog-footer">

   <el-checkbox v-model="ifyajin" style="margin-right: 100px;">预交押金</el-checkbox>

        <el-button  @click="dialogFormVisible1 = false">取 消</el-button>
        <el-button type="success" @click="handlization">保 存</el-button>
      </div>
    </el-dialog>



    <el-dialog :fullscreen='true' :close-on-click-modal='false'
      :title="tename"
      width="80%"
      @close="closeuser"
      :visible.sync="dialogFormVisible2"
    >
      <newCreate
        ref="create2"
        :patientinfo="patientinfo"
        :ifxiu='ifxiu'

        @hospitalization2="hospitalization2(arguments)"

      ></newCreate>
      <div slot="footer" class="dialog-footer">
        <el-button  @click="dialogFormVisible2 = false">取 消</el-button>
        <el-button type="success"  @click="handlization2">保 存</el-button>
      </div>
    </el-dialog>
    <!-- 住院明细 -->
        <el-dialog :close-on-click-modal='false'
      :title="mingxinane"
      width="80%"

      :visible.sync="dialogFormVisible3"
    >
      <costRecord :id='patientinfo.id' :mingxi='mingxi' ref='costR'
      @hospicostR="hospicostR(arguments)"> </costRecord>
      <div slot="footer" class="dialog-footer">
        <el-button  @click="dialogFormVisible3 = false">取 消</el-button>
        <el-button  type="success" @click="handlization3">确 定</el-button>
      </div>
    </el-dialog>
<!-- //转院备案 -->
        <el-dialog :fullscreen='true' :close-on-click-modal='false'
      title="转院备案"
      width="80%"

      :visible.sync="dialogFormVisible4"
    >
          <turncreate
        ref="create4"
        :patientinfo="patientinfo"
        :ifxiu='ifxiu'
        @hospitalization4="hospitalization4(arguments)"

      ></turncreate>

      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible4 = false">取 消</el-button>
        <el-button  type="success" @click="handlization4">确 定</el-button>
      </div>
    </el-dialog>

   <!-- 备案撤销 -->
    <el-dialog :close-on-click-modal='false' title="备案撤销" @close="closetan('cancelHospitalinfo2')"
    :visible.sync="canceldialogdeposit2" width="70%">
      <infocrad :id="patientinfo.id" ref='userinfn'></infocrad>
      <viewTitle text="备案撤销" style="font-size:20px;margin-bottom:20px" />

      <el-col :span="24">
        <el-form ref='cancelHospitalinfo2' >
          <el-form-item label="撤销原因">
            <el-input
              type="textarea"
              v-model="cancelHospitalinfo2.memo"
            ></el-input>
          </el-form-item>
        </el-form>
      </el-col>
      <div slot="footer" class="dialog-footer">
        <el-button  @click="canceldialogdeposit2 = false">取 消</el-button>
        <el-button  type="success" @click="cancelHospital2">保 存</el-button>
      </div>
    </el-dialog>
    <!-- 分床 -->
     <el-dialog :fullscreen='true' :close-on-click-modal='false' title="分床" :visible.sync="fooddialogdeposit" width="70%">
      <splitbed
        ref="splitbed"
        :patientinfo="patientinfo"
        @splitbed="splitbed(arguments)"
      >
      </splitbed>
      <div slot="footer" class="dialog-footer">
        <el-button  @click="fooddialogdeposit = false">取 消</el-button>
        <el-button  type="success" @click="handelMemberSave">保 存</el-button>
      </div>
    </el-dialog>

    <!-- 月结账单 -->
    <el-dialog :close-on-click-modal='false' title="月结账单" @close="closetan('formyue')" :visible.sync="fooddialogdeposit2" width="70%">

     <el-form  ref='formyue'  :model="formyue" label-width="100px">

  <el-form-item label="清算类别">
    <el-select v-model="formyue.clr_type"  filterable  placeholder="请选择清算类别">
         <el-option v-for="(item,index) in dictArry[0].items"  :label="item.name" :value="item.id"></el-option>

    </el-select>
  </el-form-item>
    <el-form-item label="二级清算类别">
    <el-select v-model="formyue.clr_type_lv2" filterable placeholder="请选择二级清算类别">
       <el-option v-for="(item,index) in dictArry[2].items"  :label="item.name" :value="item.id"></el-option>

    </el-select>
  </el-form-item>
    <el-form-item label="清算方式">
    <el-select v-model="formyue.clr_way" filterable placeholder="请选择清算方式">
       <el-option v-for="(item,index) in dictArry[1].items"  :label="item.name" :value="item.id"></el-option>
    </el-select>
  </el-form-item>
  <el-form-item label="日期">
    <el-col :span="11">
      <el-date-picker type="date" placeholder="选择日期" v-model="formyue.begndate" style="width: 100%;"
         format="yyyy 年 MM 月 dd 日"
      value-format="yyyy-MM-dd"></el-date-picker>
    </el-col>
    <el-col class="line" :span="2">-</el-col>
    <el-col :span="11">
     <el-date-picker type="date" placeholder="选择日期" v-model="formyue.enddate" style="width: 100%;"
         format="yyyy 年 MM 月 dd 日"
      value-format="yyyy-MM-dd"></el-date-picker>
    </el-col>
  </el-form-item>




</el-form>
      <div slot="footer" class="dialog-footer">
        <el-button  @click="fooddialogdeposit2 = false">取 消</el-button>
        <el-button  type="success" @click="handelMemberSave2">保 存</el-button>
      </div>
    </el-dialog>
     <el-dialog :fullscreen='true' :close-on-click-modal='false' title="医保结算" :visible.sync="yibaojiesuan" width="80%">
      <yibaojisuan

        :user="patientinfo2"
        :id="patientinfo.id"
      >
      </yibaojisuan>
        <!-- @jine="jine(arguments)" -->
      <div slot="footer" class="dialog-footer">
        <el-button @click="yibaojiesuan = false">取 消</el-button>
        <el-button type="success" @click="handeyibaoSave">保 存</el-button>
      </div>
    </el-dialog>
    <!-- <el-drawer
      title="我是标题"
      :visible.sync="dialogFormVisible1"
      direction="ttb"
      size="80%"
      style="height:800px;"
    >

    </el-drawer> -->
  </el-row>
</template>

<script>
import FromList from "@/forComponents/fromList/fromList";
import TopManu from "@/components/TopMenu";
import ViewTitle from "@/forComponents/viewTitle";
import Create from "./components/create";
import newCreate from "./components/newcreate";
import turncreate from "./components/turncreate.vue";
import jiezhang from "./components/jiezhang.vue";
import infocrad from "./components/infocrad.vue";
import splitbed from "./components/Splitbed.vue";
import zhenduan from "../hospital/components/zhenduan.vue";

import {
  getAllIcu,
  distributeBed,
  createDepositOrder,
  cancelHospital,
  getNurseLevel,
  readHospitalMemberDetail,
  getHospitalMember,
  dischargeHospital,
  update,
  submitHospital,
  cancelDischargeHospital,
  cancelSubmitHospital,
  dischargeSettlement,
  hospOrdUpload,
  clncExamRcdUpld,
  clncTestUpld,
  bctlClteRpotRcdUpld,
  saveNursOprtRcdCClient,
  iptInfoUpload,
  insertFixmedinsMedrcdInfo,
  hospitalRegisterEdit,
  hospitalRegisterSave,
  hospitalRegisterCancel,
  hospFeeDtlUp,
  dischargeProcess,
  dischargeUndo,
  medinsMonSetlAppyClient,
  hosTransferApply,
  hosTransferApplyCancel,
  hospSettPreSett,
  hospSettA,
  settCl,
  getDiagonsis,
  hospFeeDtCl,
  downHospReport,
  downHospSbReport,
  getYbRecord
} from "@/api/zhuyanre";
import { getOrganization } from "@/api/organization";
import { getdictIndex, create,getgetDiseaseDict } from "@/api/register";
import costRecord from "./components/costRecord.vue";
import jiaoyi from "./components/jiaoyi.vue";
import yibaojisuan from "./components/yibaojiesuan.vue";
import {mapState,mapActions } from "vuex"
let that;
export default {
  name:"yibao",
  data() {
    return {
      //就病区
      dictArry:[{items:[]},{items:[]},{items:[]},],
      tableData: [],
      tableData2:[],
      zhuyuandeposit: false,
      leftValue: "",

      //查询条件
      formInline: {
        rightKeyValue: "",
        rightRadio: [],
        range: "3",
        today:false,
        page: 1,
        limit: 10,
        icu_id: "",
        nature:'',
      },
      ifyajin:false,
      getBuildlist: [],
      Radiooptions: [
        {
          value: "1",
          label: "待入院"
        },
        {
          value: "2",
          label: "在院"
        },
        {
          value: "3",
          label: "申请出院"
        },
        {
          value: "4",
          label: "待出院"
        },
        {
          value: "5",
          label: "已出院"
        }
      ],
      Radiooptions2: [
        {
          value: "1",
          label: "个人"
        },
        {
          value: "2",
          label: "科室"
        },
        { value: "3", label: "全院" }
      ],
      total: 0,
      fooddialogdeposit: false,
      foodinfo: {
        id: "",
        pid: ""
      },
      cancelDischarge: false,
      cancelDis: {
        hospital_id: "",
        msg: ""
      },
      NurseLeveldialogdeposit: false,
    chuyuantilogdeposit:false,
    jiaoyilogdeposit:false,
      ben_list: [],
      patientlist: [],
      //当前病人信息
      patientinfo2:{},
      patientinfo: {
        nurse_levelneme: "",
        member: {
          name: "",
          gender: "",
          age: ""
        },
        wallet: {
          wallet_income: ""
        },
        doctor: { real_name: "" },
        nurse: { real_name: "" },
        bed_doctor: {
          real_name: ""
        },
        room_name: ""
      },
      mingxinane:'上传明细',
      //判断当前选中
      index_t: 0,
      dialogFormVisible1: false,
      dialogdeposit: false,

      //撤销住院
      cancelHospitalinfo: {
        id: "",
        cancel_msg: ""
      },
       //撤销备案
      cancelHospitalinfo2: {
        id: "",
        memo: ""
      },
      revoke: {
        id: "",
        cancel_msg: ""
      },
    yizhuqingkuang:[],
      //医生列表
yibaojiesuan:false,
      //押金
      orderinfo: {
        hospital_id: "",
        remark: "",
        des: "",
        payment: [
          {
            payment: 1,
            money: 0
          },
          {
            payment: 2,
            money: 0
          },
          {
            payment: 3,
            money: 0
          },
          {
            payment: 4,
            money: 0
          },
          {
            payment: 5,
            money: 0
          },
          {
            payment: 6,
            money: 0
          }
        ]
      },
      moneysum: 0,
      damoneysum: "",
      canceldialogdeposit: false,
      canceldialogdeposit2:false,
      dialogFormVisible2:false,
      fooddialogdeposit2:false,
      dialogFormVisible4:false,
    yizhulogdeposit : false,
      zhuanname:'转院备案',
      data_info:{
          count:'',
          todayEnter:'',
          todayLeave:''
      },
       selectParams2: {
        keyword: "",
       keyword2:'',
      },
        selectData2: {
        selectData1: [],
      },
      departmentoptions:[],
      TopArr2:[
           {
          type: 30,
          name: "转院备案"
        },
          {
          type: 31,
          name: "转院备案撤销"
        },
      ],
         TopArr3: [


            { name: "基金结算清单下载", type: "40" },

             { name: " 基金结算清单上传 ", type: "41" },


      ],
      apply_time:'',
      TopArr: [
        // {
        //   type: 1,
        //   name: "办理住院"
        // },

        // {
        //   type: 3,
        //   name: "入院信息变更"
        // },

        // {
        //   type: 6,
        //   name: "住院备案"
        // },
        // {
        //   type: 7,
        //   name: "转院备案撤销"
        // },
        // {
        //   type: 8,
        //   name: "出院办理"
        // },
        // {
        //   type: 9,
        //   name: "出院预结算"
        // },
        // {
        //   type: 10,
        //   name: "出院结算"
        // },
        // {
        //   type: 11,
        //   name: "出院撤销"
        // },
        // {
        //   type: 12,
        //   name: "住院结算撤销"
        // },
        // {
        //   type: 13,
        //   name: "医疗保障基金结算清单信息上传"
        // },
        // {
        //   type: 15,
        //   name: "住院结算清单单据打印"
        // },
        // {
        //   type: 16,
        //   name: "获取医疗机构信息"
        // },

         {
          type: 25,
          name: "入院登记"
        },
        {
          type: 2,
          name: "入院撤销"
        },
         {
          type: 26,
          name: "入院信息变更"
        },
           {
          type: 27,
          name: "出院办理"
        },
            {
          type: 28,
          name: "出院撤销"
        },

           {
          type: 4,
          name: "住院费用明细上传"
        },
        {
          type: 5,
          name: "住院费用明细撤销"
        },
         {
          type: 32,
          name: "住院结算单单据下载"
        },
        {
          type: 33,
          name: "商保单据下载"
        },
        // {
        //   type: 29,
        //   name: "月结申报"
        // },
        // {
        //   type: 18,
        //   name: "住院医嘱记录"
        // },
        // {
        //   type: 19,
        //   name: "临床检查报告记录"
        // },
        // {
        //   type: 20,
        //   name: "细菌培养报告记录"
        // },
        // {
        //   type: 21,
        //   name: "药敏记录报告记录"
        // },
        // {
        //   type: 22,
        //   name: "护理操作生命体征测量记录"
        // },
        // {
        //   type: 23,
        //   name: "住院病案上传"
        // },
        // {
        //   type: 24,
        //   name: "电子病例上传"
        // }
      ],
      diet_list: [],
      huli: [],
      userdata: {},
      member_lv: [],
      getIndex2: 0,
      chuyuanlogdeposit: false,
      dialogFormVisible3:false,
      dischargedata: {
        disease_arr: [],
        hospital_id: "",
        apply_time: "",
        leave_id: "",
        leave_way: "",
        leave_hospital: "",
        leave_remark: "",
        leave_yue:'',
        leave_type:'',
        department_id:'',
      },
      chuyuanfangshi: [],
      chuyuanzhuang: [],
      ifxiu:1,
      tename:'入院办理',
      mingxi:1,
      mingxiname:'住院费用明细上传',
      formyue:{
          clr_type:'',
          clr_wpy:'',
          cllr_type_lv2:'',
          begndate:'',
          enddate:''
      },
      xianzhong:[],
      yiliao:[],
      ifzhuan:true,
      diess:[],
      ifupcreate:true
    };
  },
  watch: {
    index(to) {
      if (to == 0) {
        that.loading.close();
      } else {
        that.loading = that.$loading({
          lock: true,
          text: "",
          background: "rgba(0, 0, 0, 0.7)"
        });
      }
    }
  },
  mounted() {
    that = this;
    that.getHospitalMember();
    that.getNurseLevel();
    that.getOrganization()
    that.getdiet_list();
       this.getDiseaseDict()
    getAllIcu({ level: "2" }).then(res => {
      this.getBuildlist = res.data;
    });

  },
   computed: {
    ...mapState({
      store_patientinfo: (state) => state.yibaoban.patientinfo,

    }),
  },
  methods: {

     ...mapActions([

        'yibaoban/getInfo',
    	]),
       rowClick(row,rowIndex) {
      console.log("row",this.patientinfo)
      // this.getIndex2 = rowIndex
      this.patientinfo=row

      this['yibaoban/getInfo']({id:row.id}).then(res=>{
        console.log("store_patientinfo",this.store_patientinfo)
      })
    },
    getYbRecord(id){
      getYbRecord({id:id}).then(res=>{
          this.tableData2=res.data
      })
    },
        getOrganization() {
      getOrganization().then(res => {
        console.log(res);
        this.departmentoptions = this.deleteChildren(res.data);
      });
    },
        deleteChildren(arr) {
      let childs = arr;
      for (let i = childs.length; i--; i > 0) {
        if (childs[i].children) {
          if (childs[i].children.length) {
            this.deleteChildren(childs[i].children);
          } else {
            delete childs[i].children;
          }
        }
      }
      return arr;
    },
     //获取诊断
      getDiseaseDict(e) {

       let d = {
        keyword: this.selectParams2.keyword,

      };
      getgetDiseaseDict(d)
        .then(res => {
          let data = res.data;
          console.log(data)
          this.selectData2.selectData1 = data

        })
        .catch(e => {});
    },
     getDiseaseDict2(e) {

       let d = {
        keyword: this.selectParams2.keyword2,

      };
      getgetDiseaseDict(d)
        .then(res => {
          let data = res.data;
          console.log(data)
          this.selectData2.selectData1 = data

        })
        .catch(e => {});
    },

    selectedstyle({ row, rowIndex }) {
      if (this.getIndex2 === rowIndex) {
        return {
          "background-color": "#85ce61"
        };
      }
    },
    tableRowClassName({ row, rowIndex }) {
     if (row.id === this.patientinfo.id) {
        return "success-row";
      }
    },

    //获取病人性质
    // getmember_lv() {
    //   getdictIndex({ group_id: 4 })
    //     .then(res => {
    //       let data = res.data[0].items;
    //       data.forEach((item, key) => {
    //         let arr = {
    //           name: item.name,
    //           id: item.id
    //         };
    //         that.member_lv.push(arr);
    //       });
    //     })
    //     .catch(e => {});
    // },

    //分页
    handleSizeChange(e) {
      this.formInline.limit = e;
      that.getHospitalMember();
    },
    handlePagination(e) {
      this.formInline.page = e;
      that.getHospitalMember();
    },
    //搜索
    radiochang(val) {
    console.log(val)
    this.formInline.page = 1;
      that.getHospitalMember();
    },
    //押金列表
    handdeposit() {
      this.$router.push({ path: "/workstation/DepositList" });
    },
    //结算管理
    handdepositset() {
      this.$router.push({ path: "/workstation/depositset" });
    },
    //保存  修改  住院
    handlization() {
      this.$refs.create.hospitalization();
    },
     //保存  修改  住院
    handlization2() {
      this.$refs.create2.hospitalization2();
    },
       handlization4() {
      this.$refs.create4.hospitalization4();
    },
        hospitalization4(arr){


            if (this.ifzhuan) {
                  hosTransferApply(arr[0]).then(res=>{

            })
            }else{
                  hosTransferApplyCancel(arr[0]).then(res=>{

            })

            }


    },
         //住院明细上传
    handlization3() {
     this.$refs.costR.hospicostR();

    },
    hospicostR(arr){
      var  art=arr[0].toString()
        if (this.mingxi==1) {
         hospFeeDtlUp({ id: this.patientinfo.id,fee_ids:art })
                .then(res => {
                 if (res.code==200) {
                       this.$message({
                  message: "提交成功",
                  type: "success"
                });
                 }
                })
                .catch(e => {});
      }else{
           hospFeeDtCl({ id: this.patientinfo.id,fee_ids:art})
                .then(res => {
                 if (res.code==200) {
                       this.$message({
                  message: "提交成功",
                  type: "success"
                });
                 }
                })
                .catch(e => {});
      }
    },

    closeuser() {
      this.$refs.create.closeitalization();
    },
    hospitalization(arr) {
       console.log(this.ifupcreate)
      if (this.ifupcreate) {
        if (that.ifphone(arr[0].family_phone)) {
          if (that.ifphone(arr[0].family_phone2)) {

               create(arr[0]).then(res => {
                if (res.code == 200) {
                  this.$message({
                    message: "办理成功",
                    type: "success"
                  });
                }
                // this.getHospitalMember();
                // this.dialogFormVisible1 = false;
                   if (that.ifyajin) {
                     this.dialogFormVisible1 = false;
                     that.dialogdeposit = true;
                     that.patientinfo.id=res.data.id
                  }
              });

          } else {
            this.$message("紧急联系人电话错误");
          }
        } else {
          this.$message("联系人电话错误");
        }
      } else {
        if (that.ifphone(arr[0].family_phone)) {
          if (that.ifphone(arr[0].family_phone2)) {

                   update(arr[0]).then(res => {
                if (res.code == 200) {
                  this.$message({
                    message: "修改成功",
                    type: "success"
                  });
                  this.getHospitalMember();
                  // this.dialogFormVisible1 = false;

                }
              });

          } else {
            this.$message("紧急联系人电话错误");
          }
        } else {
          this.$message("联系人电话错误");
        }
      }
    },
    ifphone(mobile) {
      var tel = /^[1][3,4,5,7,8,9][0-9]{9}$/;
      var phone = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
      if (mobile.length == 11) {
        //手机号码
        if (tel.test(mobile)) {
          console.log(mobile);
          return true;
        }
      } else if (mobile.length == 12 && mobile.indexOf("-") != -1) {
        //电话号码
        if (phone.test(mobile)) {
          console.log(mobile);
          return true;
        }
      }
      console.log("请输入有效的号码！");
    },
    hospitalization2(arr){
      console.log(arr)
          if (this.ifxiu==1) {
            hospitalRegisterSave(arr[0]).then(res=>{
              if (res.code==200) {
                this.$message({
                 message: "提交成功",
                  type: "success"
              })
                // this.dialogFormVisible2=false
              }
            })
          }else if(this.ifxiu==2){
            hospitalRegisterEdit(arr[0]).then(res=>{
                if (res.code==200) {
                this.$message({
                 message: "提交成功",
                  type: "success"
              })
                // this.dialogFormVisible2=false
              }
            })
          }else if(this.ifxiu==3){
            dischargeProcess(arr[0]).then(res=>{
               if (res.code==200) {
                this.$message({
                 message: "提交成功",
                  type: "success"
              })
                // this.dialogFormVisible2=false
              }
            })
          }
    },
    handleCurrentChange() {},

    getdiet_list() {
      getdictIndex({ group_id: "50,51,13,15,4,75,76,77" })
        .then(res => {
          let data = res.data;

          data.forEach((item, key) => {
            if (item.id == 50) {
              that.chuyuanzhuang = item.items;
            } else if (item.id == 51) {
              that.chuyuanfangshi = item.items;
            }else if(item.id==13){

             that.xianzhong=item.items;
            }else if(item.id==15){

             that.yiliao=item.items;
            }else if(item.id==4){

             that.member_lv=item.items;
            }
          });
          that.dictArry=data.filter(v=>v.id==75||v.id==76||v.id==77)
          console.log("that.dictArry",that.dictArry)
        })
        .catch(e => {});
    },
    handdejiaoyi(){
        this.jiaoyilogdeposit=true
    },
    //申请出院
    chuyuanHospital() {
        this.createAdvice()
    },
       createAdvice(arr) {
        // console.log(arr[0])

            var data = that.dischargedata;

      data.hospital_id = that.patientinfo.id;
      data.department_id=data.department_id[data.department_id.length-1]
      delete data.leave_type
      delete data.leave_yue
      data.disease_arr=[]

        //  if(arr[0]){
        //    arr[0].forEach(res=>{
        //        data.disease_arr.push({
        //           id:res.id,
        //           number:res.number,
        //           disease_id:res.disease_id,
        //           name:res.name,
        //           result_id:res.result_id,
        //           diagnostic_time: res.diagnostic_time,
        //           disease_time:res.disease_time,
        //           is_contagion: res.is_contagion?1:2,
        //           is_operation:res.is_operation?1:2,
        //           type:res.type=='入院诊断'?1:res.type=='出院诊断'?2:3
        //    })
        //    })

        //  }

      dischargeHospital(data).then(res => {
        if (res.code == 200) {
          this.chuyuanlogdeposit = false;
          that.dischargedata = {
            disease_arr: [],
            hospital_id: [],
            apply_time: "",
            leave_id: "",
            leave_way: "",
            leave_hospital: "",
            leave_remark: ""
          };
           this.$message({
                 message: "提交成功",
                  type: "success"
              })
        }
      });
     },
    //结账出院
    // zhuyuanHospital() {
    //   this.$refs.jiezhang.jiezhang();
    // },

    //撤销出院申请
    cancelDischargehade() {
      var data = that.cancelDis;
      data.hospital_id = that.patientinfo.id;
      cancelDischargeHospital(data).then(res => {
        if (res.code == 200) {
          this.cancelDischarge = false;
          this.cancelDis = {
            msg: "",
            hospital_id: ""
          };
        }
      });
    },
    getDoctorList() {
      getDoctorList({ page: that.doctorPage, limit: that.doctorSize })
        .then(res => {
          let {
            data: { list }
          } = res;
          list.forEach(item => {
            let arr = {
              number: item.id,
              dept_name: item.doctor.dept_name,
              real_name: item.doctor.real_name,
              positional_title: item.doctor.positional_title,
              register_fee: item.register_fee.register_fee,
              treat_fee: item.register_fee.treat_fee,
              look_count: item.look_count,
              user_id: item.user_id
            };
            that.doctorData.push(arr);
          });
        })
        .catch(e => {
          this.$message({
            message: e.message,
            type: "error"
          });
        });
    },
    getHospitalMember() {
      let data_t = {
        ipt_no: "",
        m_keyword: that.formInline.rightKeyValue,
        icu_id: "",
        bed: "",
        status: that.formInline.rightRadio.toString(),
        doctor_id: "",
        nurse_id: "",
        dept_id: "",
        nature:that.formInline.nature,
        today:that.formInline.today?1:'',
        range: that.formInline.range,
        page: that.formInline.page,
        limit: that.formInline.limit,
        source:3
      };
      getHospitalMember(data_t)
        .then(res => {
          let data = res.data.list;
          that.total = res.data.count;
          that.data_info=res.data
          that.patientlist = [];
          if (data.length != 0) {
            data.forEach((item, key) => {
              let arr = {
                ipt_no: item.ipt_no,
                id: item.id,
                name: item.member.name,
                id_card: item.member.id_card
              };
              that.tableData.push(arr);
            });
            that.patientlist = data;
            for (var i in that.patientlist) {
              that.patientlist[i].room_name= that.patientlist[i].room_info[2]+that.patientlist[i].room_info[3]
              that.patientlist[i].member.gender =
                that.patientlist[i].member.gender == 1
                  ? "男"
                  : that.patientlist[i].member.gender == 2
                  ? "女"
                  : "其他";
                    that.patientlist[i].mdtrt_name=that.patientlist[i].mdtrt_id=='0'?'未登记':'已登记'
              that.patientlist[i].nurse_levelneme = that.mapping(
                that.patientlist[i].nurse_level
              );
              that.patientlist[i].memberNature = that.mapxing(
                that.patientlist[i].member.nature
              );
               that.patientlist[i].member.insutype = that.mapxian(
                that.patientlist[i].member.insutype
              );
              that.patientlist[i].med_type = that.mapyiliao(
                that.patientlist[i].med_type
              );

              if (that.patientlist[i].disease) {
                that.patientlist[i].diseaseName = that.patientlist[
                  i
                ].disease.map(item => {
                  return item.disease_name;
                });
                that.patientlist[i].diseaseName = that.patientlist[
                  i
                ].diseaseName.join("&");
              }
            }

            that.patientinfo = data[0];
              this['yibaoban/getInfo']({id:that.patientinfo.id}).then(res=>{
                console.log("store_patientinfo",this.store_patientinfo)
              })
            // that.$refs.userinfn.readHospitalMemberDetail(patientinfo.id)
          }
        })
        .catch(e => {
          this.$message({
            message: e.message,
            type: "error"
          });
        });
    },
    //
    mapping(num) {
      var art = "";

         that.huli.map(function(value,i,array){

            if (value.id == num) {
          art = value.name;
        }

       })
        return art;
    },
    //匹配斌人性质
    mapxing(num) {
      var art = "";
         that.member_lv.map(function(value,i,array){

            if (value.id == num) {
          art = value.name;
        }

       })
        return art;
    },
    //匹配险种
    mapxian(num) {
      var art = "";
       that.xianzhong.map(function(value,i,array){

            if (value.id == num) {
          art = value.name;
        }

       })
      return art;
    },
      //匹配医疗
    mapyiliao(num) {
       var art = "";
      that.yiliao.map(function(value,i,array){

            if (value.id == num) {
          art = value.name;
        }

       })
      return art;


    },
    //住院修改
    handupdata() {

      readHospitalMemberDetail({ id: that.patientinfo.id }).then(res => {
        console.log(res);
        if (res.code == 200) {
          that.userdata = res.data;

          that.dialogFormVisible1 = true;
        }
      });
    },

    // //设置饮食
    // setFood() {
    //   that.fooddialogdeposit = true;
    //   that.getdiet_list();
    // },
    // //设置饮食
    // foodHospital() {
    //   var data_t = that.foodinfo;
    //   data_t.id = that.patientinfo.id;
    //   setFood(data_t)
    //     .then(res => {
    //       // let data = res.data;
    //       // console.log(res);
    //       if (res.code == 200) {
    //         that.fooddialogdeposit = false;
    //       }
    //     })
    //     .catch(e => {});
    // },
    //设置护理等级
    // setNurseLevel() {
    //   that.NurseLeveldialogdeposit = true;
    //   that.getNurseLevel();
    // },
    //获取护理等级
    getNurseLevel() {
      getNurseLevel({}).then(res => {
        that.huli = res.data;
      });
    },
  //撤销住院
    cancelHospital() {
      var data = that.cancelHospitalinfo;
      data.id = that.patientinfo.id;
      cancelHospital(data)
        .then(res => {
          // let data = res.data;
          // console.log(res);
          if (res.code == 200) {
            that.cancelHospitalinfo={
              id: "",
        cancel_msg: ""
            }
            that.canceldialogdeposit = false;
          }
        })
        .catch(e => {});
    },
     readHospitalMemberDetail(){
        readHospitalMemberDetail({id:this.patientinfo.id}).then(res=>{
            console.log(111,res)
             var objdata={}
            //  this.money=res.data.money
        Object.assign(objdata, res.data.masterInfo, res.data.nodeInfo,res.data.member);
        this.patientinfo2=objdata
        this.patientinfo2.room_info=objdata.room_name && objdata.room_name.split('/')
         this.yibaojiesuan=true
        })
      },
    //撤销备案
      cancelHospital2() {
      var data = that.cancelHospitalinfo2;
      data.id = that.patientinfo.id;
      data.member_id=this.patientinfo.member.id
      hosTransferApplyCancel(data)
        .then(res => {
          // let data = res.data;
          // console.log(res);
          if (res.code == 200) {
            that.cancelHospitalinfo={
              id: "",
              memo: ""
            }
            that.canceldialogdeposit2 = false;
          }
        })
        .catch(e => {});
    },
    //切换病人
    Select(i) {
      that.patientinfo = that.patientlist[i];
    },
    //分床
    handsplitben() {
      that.fooddialogdeposit = true;
    },
    //保存  分床
    handelMemberSave(arr) {
      this.$refs.splitbed.splitbed();
    },
      splitbed(arr) {

      var data_tt = arr[0];

      console.log(data_tt);

      distributeBed(data_tt)
        .then(res => {
          console.log(res);
          if (res.code == 200) {
            that.getHospitalMember();
            that.fooddialogdeposit = false;
          }
        })
        .catch(e => {});
    },
     //月结
    handelMemberSave2() {
      var data_t=this.formyue
      medinsMonSetlAppyClient(data_t).then(res=>{
            if (res.code==200) {
              this.$message({
                 message: "提交成功",
                  type: "success"
              })
            that.formyue={
                clr_type:'',
          clr_wpy:'',
          cllr_type_lv2:'',
          begndate:'',
          enddate:''
            }
            // that.fooddialogdeposit2=false
            }
      })
    },

    tijiaochuyuan(){
            submitHospital({
              hospital_id: that.patientinfo.id,
              leave_time:that.apply_time
            }).then(res => {
              if (res.code == 200) {
                this.$message({
                  message: "提交成功",
                  type: "success"
                });
                that.chuyuantilogdeposit=false
                that.getHospitalMember()
              } else {
                //  this.$message(res.message);
              }
            });
    },
    handleCommand(command) {
      console.log(command);
      let arr = command;
      this.Select(arr[1]);

      switch (arr[2]) {
        //押金
        case "y":
          that.dialogdeposit = true;
          break;
        case "c":
          that.canceldialogdeposit = true;
          break;
        case "cy":
          that.chuyuanlogdeposit = true;
          getDiagonsis({id:that.patientinfo.id}).then(res=>{
            console.log(res)
          })
          break;
        case "cxcy":
          that.cancelDischarge = true;
          break;

        case "x":
          that.ifupcreate=false
          that.handupdata();
          break;
        case "f":
          that.handsplitben();
          break;
        case "tj":
          that.chuyuantilogdeposit=true
          break;
        case "cxtj":
          this.$confirm("是否撤销提交出院", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消"
          }).then(() => {
            cancelSubmitHospital({
              hospital_id: arr[0]
            }).then(res => {
              if (res.code == 200) {
                this.$message({
                  message: "撤销成功",
                  type: "success"
                });
              } else {
                //  this.$message(res.message);
              }
            });
          });
          break;
        case "jzcy":
          this.zhuyuandeposit = true;
          break;
          case "jzyz":
          this.yizhulogdeposit = true;
          break;
          case "qdxz":
            if(command[0] == 16){
              window.open("http://hospital.boxinyao.com/2109278916818.pdf")
            }else{
              this.$router.push({
                path: "/bai/medicalList",
                query: { id: that.patientinfo.id}
              });
            }

          break;
          case "qdsc":
         this.$router.push({
          path: "/workstation/qingdan",
          query: { id: that.patientinfo.id}
        });
          break;

      }
    },

    //住院办理
    handcreate() {
      // console.log('22')
      that.ifupcreate=true
      that.dialogFormVisible1 = true;
    },
    //清单
    // handqingdan() {
    //   if (that.getIndex2 == 0) {

    //   } else if (that.getIndex2 == 1) {
    //     this.$router.push({
    //       path: "/bai/medicalList",
    //       query: { id: 2 }
    //     });
    //   } else if (that.getIndex2 == 2) {
    //     this.$router.push({
    //       path: "/bai/medicalList",
    //       query: { id: 4 }
    //     });
    //   } else {
    //     this.$router.push({
    //       path: "/bai/medicalList",
    //       query: { id: 3 }
    //     });
    //   }
    // },
    handedeposit() {
      var data_tt = that.orderinfo;
      data_tt.hospital_id = that.patientinfo.id;
      createDepositOrder(data_tt)
        .then(res => {
          let data = res.data;
          that.getHospitalMember();
          that.dialogdeposit = false;
        })
        .catch(e => {});
    },
    //押金总和
    moneysumfun() {
      var arr = that.orderinfo.payment;
      var num = 0;
      var num1 = that.NumberAdd(num, parseFloat(arr[0].money));
      var num2 = that.NumberAdd(num1, parseFloat(arr[1].money));
      var num3 = that.NumberAdd(num2, parseFloat(arr[2].money));
      var num4 = that.NumberAdd(num3, parseFloat(arr[3].money));
      var num5 = that.NumberAdd(num4, parseFloat(arr[4].money));
      that.moneysum = that.NumberAdd(num5, parseFloat(arr[5].money));
      that.damoneysum = that.AmountLtoU(that.moneysum);
    },
    AmountLtoU(num) {
      ///<summery>小写金额转化大写金额</summery>
      ///<param name=num type=number>金额</param>
      if (isNaN(num)) return "";
      var strPrefix = "";
      if (num < 0) strPrefix = "(负)";
      num = Math.abs(num);
      if (num >= 1000000000000) return "无效数值！";
      var strOutput = "";
      var strUnit = "仟佰拾亿仟佰拾万仟佰拾元角分";
      var strCapDgt = "零壹贰叁肆伍陆柒捌玖";
      num += "00";
      var intPos = num.indexOf(".");
      if (intPos >= 0) {
        num = num.substring(0, intPos) + num.substr(intPos + 1, 2);
      }
      strUnit = strUnit.substr(strUnit.length - num.length);
      for (var i = 0; i < num.length; i++) {
        strOutput +=
          strCapDgt.substr(num.substr(i, 1), 1) + strUnit.substr(i, 1);
      }
      return (
        strPrefix +
        strOutput
          .replace(/零角零分$/, "整")
          .replace(/零[仟佰拾]/g, "零")
          .replace(/零{2,}/g, "零")
          .replace(/零([亿|万])/g, "$1")
          .replace(/零+元/, "元")
          .replace(/亿零{0,3}万/, "亿")
          .replace(/^元/, "零元")
      );
    },
    handeyibaoSave(){

    },
    handjsdata(){
         this.$router.push({
          path: "/workstation/jiezhang",
          query: { id: this.patientinfo.id,uid:this.patientinfo.member.id }
        });
    },
    handelDropdown(e) {
      console.log(e,'0000')
      switch (e) {
        case 1:
          this.$prompt("请输入住院id", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消"
          })
            .then(({ value }) => {
              hospitalRegisterSave({ id: value })
                .then(res => {
                  this.$alert(res.message, "提示", {
                    confirmButtonText: "确定"
                  });
                })
                .catch(e => {});
            })
            .catch(() => {
              this.$message({
                type: "info",
                message: "取消输入"
              });
            });

          break;
        case 2:
          this.$confirm('是否撤销入院?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
            hospitalRegisterCancel({ id: that.patientinfo.id })
                .then(res => {
                 if (res.code==200) {
                    this.$message({
            type: 'success',
            message: '成功!'
          });
                 }
                })
                .catch(e => {});

        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消'
          });
        });

          break;
        case 3:

            this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
            hospitalRegisterCancel({ id: value })
                .then(res => {
                 if (res.code==200) {
                    this.$message({
            type: 'success',
            message: '成功!'
          });
                 }
                })
                .catch(e => {});

        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消'
          });
        });
          break;
        case 4:
          // this.$prompt("请输入住院id", "提示", {
          //   confirmButtonText: "确定",
          //   cancelButtonText: "取消"
          // })
          //   .then(({ value }) => {
          //     hospFeeDtlUp({ id: value })
          //       .then(res => {
          //         this.$alert(res.message, "提示", {
          //           confirmButtonText: "确定"
          //         });
          //       })
          //       .catch(e => {});
          //   })
          //   .catch(() => {
          //     this.$message({
          //       type: "info",
          //       message: "取消输入"
          //     });
          //   });
            this.dialogFormVisible3=true
            this.mingxi=1
             this.mingxiname='住院费用明细上传'
          break;
        case 5:
           this.dialogFormVisible3=true
            this.mingxi=2
            this.mingxiname='住院费用明细撤销'
          // this.$prompt("请输入住院id", "提示", {
          //   confirmButtonText: "确定",
          //   cancelButtonText: "取消"
          // })
          //   .then(({ value }) => {
          //     //1
          //     hospFeeDtCl({ id: value })
          //       .then(res => {
          //         this.$alert(res.message, "提示", {
          //           confirmButtonText: "确定"
          //         });
          //       })
          //       .catch(e => {});
          //     //2
          //   })
          //   .catch(() => {
          //     this.$message({
          //       type: "info",
          //       message: "取消输入"
          //     });
          //   });

          break;
        case 6:
          this.$prompt("请输入住院id", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消"
          })
            .then(({ value }) => {
              //1
              hosTransferApply({ id: value })
                .then(res => {
                  this.$alert(res.message, "提示", {
                    confirmButtonText: "确定"
                  });
                })
                .catch(e => {});
              //2
            })
            .catch(() => {
              this.$message({
                type: "info",
                message: "取消输入"
              });
            });

          break;
        case 7:
          this.$prompt("请输入住院id", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消"
          })
            .then(({ value }) => {
              //1
              hosTransferApplyCancel({ id: value })
                .then(res => {
                  this.$alert(res.message, "提示", {
                    confirmButtonText: "确定"
                  });
                })
                .catch(e => {});
              //2
            })
            .catch(() => {
              this.$message({
                type: "info",
                message: "取消输入"
              });
            });

          break;
        case 8:
          this.$prompt("请输入住院id", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消"
          })
            .then(({ value }) => {
              //1
              dischargeProcess({ id: value })
                .then(res => {
                  this.$alert(res.message, "提示", {
                    confirmButtonText: "确定"
                  });
                })
                .catch(e => {});
              //2
            })
            .catch(() => {
              this.$message({
                type: "info",
                message: "取消输入"
              });
            });

          break;
        case 9:
          this.$prompt("请输入住院id", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消"
          })
            .then(({ value }) => {
              //1
              hospSettPreSett({ id: value })
                .then(res => {
                  this.$alert(res.message, "提示", {
                    confirmButtonText: "确定"
                  });
                })
                .catch(e => {});
              //2
            })
            .catch(() => {
              this.$message({
                type: "info",
                message: "取消输入"
              });
            });

          break;
        case 10:
          this.$prompt("请输入住院id", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消"
          })
            .then(({ value }) => {
              //1
              hospSettA({ id: value })
                .then(res => {
                  this.$alert(res.message, "提示", {
                    confirmButtonText: "确定"
                  });
                })
                .catch(e => {});
              //2
            })
            .catch(() => {
              this.$message({
                type: "info",
                message: "取消输入"
              });
            });
          break;
        case 11:
          this.$prompt("请输入住院id", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消"
          })
            .then(({ value }) => {
              //1
              dischargeUndo({ id: value })
                .then(res => {
                  this.$alert(res.message, "提示", {
                    confirmButtonText: "确定"
                  });
                })
                .catch(e => {});
              //2
            })
            .catch(() => {
              this.$message({
                type: "info",
                message: "取消输入"
              });
            });
          break;
        case 12:
          this.$prompt("请输入住院id", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消"
          })
            .then(({ value }) => {
              //1
              settCl({ id: value })
                .then(res => {
                  this.$alert(res.message, "提示", {
                    confirmButtonText: "确定"
                  });
                })
                .catch(e => {});
              //2
            })
            .catch(() => {
              this.$message({
                type: "info",
                message: "取消输入"
              });
            });
          break;
        case 13:
          this.$prompt("请输入住院id", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消"
          })
            .then(({ value }) => {
              //1
              uploadMedinfo({ id: value })
                .then(res => {
                  this.$alert(res.message, "提示", {
                    confirmButtonText: "确定"
                  });
                })
                .catch(e => {});
              //2
            })
            .catch(() => {
              this.$message({
                type: "info",
                message: "取消输入"
              });
            });

          break;
        // case 14:

        //    this.$prompt('请输入住院id', '提示', {
        //   confirmButtonText: '确定',
        //   cancelButtonText: '取消',
        // }).then(({value  }) => {
        //   //1
        //      checkSettlement({ id: value })
        //     .then((res) => {
        //       this.$alert(res.message, "提示", {
        //         confirmButtonText: "确定",
        //       });
        //     })
        //     .catch((e) => {});
        //     //2
        // }).catch(() => {
        //   this.$message({
        //     type: 'info',
        //     message: '取消输入'
        //   });
        // });
        //   break;
        case 15:
          printHospita({ id: that.patientinfo.id })
            .then(res => {
              let link = document.createElement("a");

              link.setAttribute("href", res.data);

              link.click();
            })
            .catch(e => {});

          break;
        case 16:
          that.dialogFormVisible = true;
          break;
        case 17:
          this.$prompt("请输入身份证号", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消"
          })
            .then(({ value }) => {
              //1
              queryPsnPriority({ id_card: value })
                .then(res => {
                  this.$alert(res.message, "提示", {
                    confirmButtonText: "确定"
                  });
                })
                .catch(e => {});
              //2
            })
            .catch(() => {
              this.$message({
                type: "info",
                message: "取消输入"
              });
            });

          break;
        //医保二批
        case 18:
          hospOrdUpload({ id: that.patientinfo.id })
            .then(res => {
              if (res.code == 200) {
                this.$message({
                  message: "请求成功",
                  type: "success"
                });
              }
            })
            .catch(e => {});

          break;
        case 19:
          clncExamRcdUpld({ id: that.patientinfo.id })
            .then(res => {
                 if (res.code == 200) {
                this.$message({
                  message: "请求成功",
                  type: "success"
                });
              }
            })
            .catch(e => {});

          break;
        case 20:
          clncTestUpld({ id: that.patientinfo.id })
            .then(res => {
                 if (res.code == 200) {
                this.$message({
                  message: "请求成功",
                  type: "success"
                });
              }
            })
            .catch(e => {});

          break;
        case 21:
          bctlClteRpotRcdUpld({ id: that.patientinfo.id })
            .then(res => {
                 if (res.code == 200) {
                this.$message({
                  message: "请求成功",
                  type: "success"
                });
              }
            })
            .catch(e => {});

          break;
        case 22:
          saveNursOprtRcdCClient({ id: that.patientinfo.id })
            .then(res => {
                 if (res.code == 200) {
                this.$message({
                  message: "请求成功",
                  type: "success"
                });
              }
            })
            .catch(e => {});

          break;
        case 23:
          iptInfoUpload({ id: that.patientinfo.id })
            .then(res => {
                 if (res.code == 200) {
                this.$message({
                  message: "请求成功",
                  type: "success"
                });
              }
            })
            .catch(e => {});

          break;
        case 24:
          insertFixmedinsMedrcdInfo({ id: that.patientinfo.id })
            .then(res => {
                 if (res.code == 200) {
                this.$message({
                  message: "请求成功",
                  type: "success"
                });
              }
            })
            .catch(e => {});

          break;
            case 25:

              this.dialogFormVisible2=true
              this.ifxiu=1
              this.tename='入院办理'
          break;
           case 26:

              this.dialogFormVisible2=true
              this.ifxiu=2
              this.tename='入院信息变更'
          break;
            case 27:

              this.dialogFormVisible2=true
              this.ifxiu=3
              this.tename='出院办理'
          break;
           case 28:
          this.$confirm('是否撤销出院?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
            dischargeUndo({ id: that.patientinfo.id })
                .then(res => {
                 if (res.code==200) {
                    this.$message({
            type: 'success',
            message: '成功!'
          });
                 }
                })
                .catch(e => {});

        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消'
          });
        });

          break;
              case 29:

              this.fooddialogdeposit2=true

          break;
              case 30:
             this.ifzhuan=true
             this.zhuanname='转院备案'
              this.dialogFormVisible4=true

          break;
            case 31:

              this.canceldialogdeposit2=true

          break;
           case 32:

              this.downHospReport()


          break;
        case 33:

          this.downHospSbReport()
          break;
           case 40:
               this.readHospitalMemberDetail()


          break;

      }
    },
    handelDropdown2(e){
        if(e==40){
        this.$router.push({
                path: "/bai/medicalList",
                query: { id: that.patientinfo.id}
              });
        }else{
          this.$router.push({
          path: "/workstation/qingdan",
          query: { id: that.patientinfo.id}
        });
        }
    },
       downHospReport(){
      var data_t={
       id:this.patientinfo.id,
       psn_name:this.patientinfo.member.name
      }
      console.log(data_t)
      downHospReport(data_t).then(res=>{
           if(res.code==200){
             const a = document.createElement('a'); // 创建a标签
            a.setAttribute('download', '');// download属性
            a.setAttribute('href', this.$http+'/'+res.data.path);// href链接
            a.click()

             }
      })
    },
    downHospSbReport(){
      var data_t={
        id:this.patientinfo.id,
        psn_name:this.patientinfo.member.name
      }
      console.log(data_t)
      downHospSbReport(data_t).then(res=>{
        if(res.code==200){
          const a = document.createElement('a'); // 创建a标签
          a.setAttribute('download', '');// download属性
          a.setAttribute('href', this.$http+'/'+res.data.path);// href链接
          a.click()

        }
      })
    },
    closetan(title){
      if(title=='orderinfo'){
          that. orderinfo={
        hospital_id: "",
        remark: "",
        des: "",
        payment: [
          {
            payment: 1,
            money: 0
          },
          {
            payment: 2,
            money: 0
          },
          {
            payment: 3,
            money: 0
          },
          {
            payment: 4,
            money: 0
          },
          {
            payment: 5,
            money: 0
          },
          {
            payment: 6,
            money: 0
          }
        ]
      },
      that.moneysum=''
      that.damoneysum=''
      }else if (title=='cancelDis') {
          that.cancelDis={
            msg: "",
            hospital_id: ""
          }
      }else if (title=='formyue') {
        that.formyue={
              clr_type:'',
          clr_wpy:'',
          cllr_type_lv2:'',
          begndate:'',
          enddate:''
        }
      }else if (title=='cancelHospitalinfo') {
        that.cancelHospitalinfo={
            id: "",
        cancel_msg: ""
        }
      }




    }
  },
  components: {
    FromList,
    TopManu,
    ViewTitle,
    Create,
    newCreate,
    jiezhang,
    infocrad,
    splitbed,
    costRecord,
    turncreate,
    zhenduan,
   jiaoyi,

   yibaojisuan
  }
};
</script>
<style >
.el-table .success-row {
    background: #409EFF !important;
}
</style>
<style lang="scss" scoped>
@import "./index.css";

.el-card__body {
  padding: 0px;
}

.img_box {
  width: 46px;
  height: 46px;
}
.span_title {
  font-weight: bold;
}
.img_kong_box {
  margin: auto;
  width: 90%;
  margin-top: 90px;
}
.cardhover {
  width: 280px;
  min-height: 280px;
}
.cardhover:hover {
  background: #aeecd1c2;
}
.img_kong {
  width: 100%;
  height: auto;
  margin: auto;
}
.zaiinfo{
 margin:20px 20px;
  padding:0px 10px;
  border-left:4px solid rgb(133, 206, 97);
  font-size: 24px;
}
.hospitalNurse-right {
    padding: 0 20px;
    padding-top: 10px;
    border-left: 1px solid #42b983;
    ;
}
.el-table .success-row {
  background: #409EFF !important;

}
</style>
